<?php
class Admin_Model_Category extends Zend_Db_Table_Abstract
{
	public function add($id,$name,$date,$id_user,$textarea,$folder)
	{
		$db = Zend_Registry::get('connectDB');
		$data = array('id_catelog'=>$id,'name_catelog'=>$name,'datecatelog'=>$date,'id_user'=>$id_user,'descrip'=>$textarea,'folder_category'=>$folder);
		$add = $db->insert('catelory',$data);
		return $add;
	}
	public function edit($id,$name,$date,$id_user,$textarea)
	{
		$db = Zend_Registry::get('connectDB');
		$data = array('name_catelog'=>$name,'datecatelog'=>$date,'id_user'=>$id_user,'descrip'=>$textarea);
		$where = $db->quoteInto('id_catelog =?',$id);
		$update = $db->update('catelory',$data,$where);
		return $update;
	}
	public function getAll()
	{
		$db = Zend_Registry::get('connectDB');
		$data = $db->fetchAll($db->select()->from('catelory')->joinInner('users','users.id_user=catelory.id_user'));
		return $data;
	}
	public function getId($id)
	{
		$db = Zend_Registry::get('connectDB');
		$data = $db->fetchRow($db->select()->from('catelory')->where('id_catelog =?',$id));
		return $data;
	}
	public function search($content)
	{
		$db = Zend_Registry::get('connectDB');
		$where = $db->quoteInto('name_catelog LIKE ? OR id_catelog LIKE ? OR datecatelog LIKE ?','%'.$content.'%');
		$data = $db->fetchAll($db->select()->from('catelory')->joinInner('users','users.id_user=catelory.id_user')->where($where));
		return $data;
	}
	public function delete($id)
	{
		$db = Zend_Registry::get('connectDB');
		$where = $db->quoteInto('id_catelog =?',$id);
		$delete = $db->delete('catelory',$where);
		return $delete;
	}
}